home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000072_icon-group-sender _Wed Mar 5 21:02:39 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Thu, 6 Mar 1997 09:23:14 MST
  2. Date: Wed, 5 Mar 1997 21:02:39 -0600
  3. Message-Id: <199703060302.VAA29037@ns1.cmpu.net>
  4. Mime-Version: 1.0
  5. Content-Type: text/plain
  6. Content-Transfer-Encoding: 7bit
  7. From: gep2@computek.net
  8. Subject: Recursive directory traversal in Icon
  9. To: icon-group@cs.arizona.edu
  10. X-Mailer: SPRY Mail Version: 04.00.06.17
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1979
  14.  
  15. >I've been reading the Icon web references, trying to decide if I 
  16. should forsake Perl in favor of Icon, and I have two questions.
  17.  
  18. >(1) How do I traverse a hierarchical directory structure in Icon? I found 
  19.     chdir, but I didn't find the equivalent of 'ls' and 'stat'. Is there 
  20.     a way to do this in Icon, or do you rely on the external environment?
  21.  
  22. In SNOBOL4+, what I did was to write a loadable function DIRFNC() which allows 
  23. you to get all the directory information for a given file (or other directory 
  24. entry, and accepting wildcards).  It also permits you to get volume labels and 
  25. subdirectory names in the same way... once you have that, it's fairly simple to 
  26. write a recursive tree traversing routine.
  27.  
  28. The alternative (and which honestly I use a significant fraction of the time, 
  29. even having the loadable function I wrote) is to simply execute the external 
  30. MS-DOS DIR command (which now permits getting all the directory recursions with 
  31. the /S option) and either route the output into a temporary file, or pipe it 
  32. directly into the S-BOL program.  Regenerating all the complete filenames with 
  33. paths is a pretty trivial pattern match from that point.
  34.  
  35. I think the reason why this kind of thing hasn't been incorporated into the 
  36. language itself is because by its nature it's quite operating system dependent, 
  37. whereas both Icon and S-BOL are designed to be as independent of the underlying 
  38. operating system as possible.
  39.  
  40. >(2) Why no module system? I've found modules helpful in every language I've 
  41.     worked with, and Icon doesn't seem to be different in that it could use
  42.     such a system. I noticed someone else mention this, but it is not in
  43.     the FAQ. Perl has benefitted greatly from the inclusion of modules.
  44.  
  45. The inclusion feature in SNOBOL4+ makes it quite simple to load subroutines as 
  46. needed from one or more library subdirectories, and automatically suppresses 
  47. duplicate requests.
  48.  
  49. Gordon Peterson
  50. http://www.computek.net/public/gep2/
  51.  
  52.